﻿
using AduSkin.Controls.Metro;
using AduSkin.Interactivity;
using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command;
using Helper.View;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;

namespace Helper.ViewModel
{
    public class MainViewModel : ViewModelBase
    {
        public MainViewModel()
        {

        }
        public void NoticeTip()
        {
            NoticeManager.NotifiactionShow.AddNotifiaction(new NotifiactionModel()
            {
                Title = "学习助手提示",
                Content = "已经最小化至后台托管"
            });
        }
        /// <summary>
        /// 打开视图
        /// </summary>
        public ICommand OpenClick => new RelayCommand<string>((e) =>
        {
            switch (e)
            {
                case "AduSkinDemo":

                    return;
                default:
                    break;
            }
        });
        /// <summary>
        /// 重新打开窗口
        /// </summary>
        public ICommand ShowWindowCommand => new RelayCommand(() =>
        {
            Application.Current.MainWindow = new MainWindow();
            Application.Current.MainWindow.Show();
            Debug.WriteLine("ShowWindowCommand 遍历=" + Application.Current.MainWindow.Title);

            foreach (Window window in Application.Current.Windows)
            {
                Debug.WriteLine("ShowWindowCommand 遍历=" + window.Title);
             
            }

        },
            () => {
                if (Application.Current.MainWindow == null) return true;
                if (Application.Current.MainWindow.Title == "学习助手"&& !Application.Current.MainWindow.IsVisible) return false;
                else return true;
            });
        /// <summary>
        /// 隐藏窗口
        /// </summary>
        public ICommand HideWindowCommand => new RelayCommand(() =>
        {
            foreach (Window window in Application.Current.Windows)
            {
                Debug.WriteLine("HideWindowCommand 遍历=" + window.Title);
                if (window.Title == "学习助手")
                {
                    Debug.WriteLine("HideWindowCommand   关闭窗口");
                    window.Hide();
                }
            }

        },()=> {
            foreach (Window window in Application.Current.Windows)
            {
               
                if (window.Title == "学习助手" && window.IsVisible)
                {
                    return true;
                }
            }
            return false;
        });
        /// <summary>
        /// 退出程序
        /// </summary>
        public ICommand ExitAppCommand => new RelayCommand(() =>
        {
            Debug.WriteLine("ExitWindowCommand");

            Application.Current.Shutdown();
        });
        /// <summary>
        /// 学习任务栏
        /// </summary>
        private UserControl _StudyTaskBar = new StudyTaskbar();
        public UserControl StudyTaskBar
        {
            get { return _StudyTaskBar; }
            set { Set(ref _StudyTaskBar, value); }
        }
        ///// <summary>
        ///// 实用案例
        ///// </summary>
        //private UserControl _PracticalCase = new PracticalCase();
        //public UserControl PracticalCase
        //{
        //   get { return _PracticalCase; }
        //   set { Set(ref _PracticalCase, value); }
        //}
        ///// <summary>
        ///// 关于
        ///// </summary>
        //private UserControl _AduSkinAbout = new AduSkinAbout();
        //public UserControl AduSkinAbout
        //{
        //   get { return _AduSkinAbout; }
        //   set { Set(ref _AduSkinAbout, value); }
        //}
        ///// <summary>
        ///// 支持与赞助
        ///// </summary>
        //private UserControl _AduSkinSupport = new AduSkinSupport();
        //public UserControl AduSkinSupport
        //{
        //   get { return _AduSkinSupport; }
        //   set { Set(ref _AduSkinSupport, value); }
        //}
    }
}
